import React, { useEffect, useState } from 'react'

export default function App3() {
    const [person,setPerson]=useState([{
        id: '001',
        name: '神里凌华'
    }, {
        id: '002',
        name: '神里凌人'
    }, {
        id: '003',
        name: '枫原万叶'
    }])
    useEffect(()=>{
        console.log('人物添加成功');
    },[person])
    const addPerson=()=>{
        setPerson([...person,{id:Date.now(),name:'xxxx'}])
    }
  return (
    <div>
        <button onClick={addPerson}>submit</button>
        <ul>
        {
            person.map(item=>{
                return <li key={item.id}>{item.name}</li>
            })
        }
        </ul>
    </div>
  )
}
